#include<iostream>
#include"contacts.pb.h"
#include<string>
using namespace std;
int main()
{
    string peostr;
    {
        conntacts::PeopleInfo people;
        people.set_name("大兵");
        people.set_age(24);
        if(!people.SerializeToString(&peostr))
        {
            cout<<"序列化失败"<<endl;
            return 1;
        }
        cout<<"序列化成功"<<endl;
        cout<<"序列化结果："<<peostr<<endl;
    }
    {
        conntacts::PeopleInfo people;
        if(!people.ParseFromString(peostr))
        {
            cout<<"反序列化失败"<<endl;
            return 1;
        }
        cout<<"反序列化成功"<<endl;
        cout<<"反序列化结果："<<endl
            <<"name:"<<people.name()<<endl
            <<"age:"<<people.age()<<endl;
    }
    return 0;
}